package com.huc.design.behavior.templatemethod.casedemo;

/**
 * @author huc
 * @version 1.0
 * @note 目的 把东西装进冰箱里面
 * @date 2021/10/8 10:20
 */
public abstract class AbstractTask {

    public void doTask(String name) {
        doOpen();
        if (doCheck()) {
            doTakeOut();
        }
        doPut(name);
        doClose();
    }

    private void doClose() {
        System.out.println("关闭冰箱门");
    }

    private void doPut(String name) {
        System.out.println("把" + name + "放入冰箱冰箱");
    }

    private void doTakeOut() {
        System.out.println("把冰箱里东西拿出来");
    }

    protected abstract boolean doCheck();


    protected void doOpen() {
        System.out.println("打开冰箱门");
    }

}
